/*! 
 * \file test_parser_adapter_basic.cpp
 * \project WonderTrader
 *
 * \author Generated
 * \date 2024/03/20
 * 
 * \brief ParserAdapter基础功能测试
 */

#include <gtest/gtest.h>
#include <memory>

// 包含必要的头文件
#include "../../src/WtCore/ParserAdapter.h"
#include "../../src/Includes/WTSDataDef.hpp"

using namespace wtp;

/**
 * @class ParserAdapterBasicTest
 * @brief ParserAdapter基础功能测试类
 */
class ParserAdapterBasicTest : public ::testing::Test {
protected:
    void SetUp() override {
        adapter_ = std::make_unique<ParserAdapter>();
    }
    
    void TearDown() override {
        adapter_.reset();
    }

protected:
    std::unique_ptr<ParserAdapter> adapter_;
};

/**
 * @brief 测试ParserAdapter基础构造
 */
TEST_F(ParserAdapterBasicTest, TestBasicConstruction) {
    EXPECT_NE(adapter_, nullptr);
    EXPECT_STREQ(adapter_->id(), "");
}

/**
 * @brief 测试代码集合操作
 */
TEST_F(ParserAdapterBasicTest, TestCodeSetOperations) {
    CodeSet codes;
    EXPECT_TRUE(codes.empty());
    
    codes.insert("SHFE.rb2405");
    EXPECT_EQ(codes.size(), 1);
    EXPECT_TRUE(codes.find("SHFE.rb2405") != codes.end());
}

/**
 * @brief 测试Tick数据结构
 */
TEST_F(ParserAdapterBasicTest, TestTickDataStructure) {
    const char* code = "SHFE.rb2405";
    
    WTSTickData* tick = WTSTickData::create(code);
    ASSERT_NE(tick, nullptr);
    
    EXPECT_STREQ(tick->code(), code);
    EXPECT_EQ(tick->tradingdate(), 0);
    
    tick->release();
}

/**
 * @brief 测试内存管理
 */
TEST_F(ParserAdapterBasicTest, TestMemoryManagement) {
    std::vector<WTSTickData*> ticks;
    
    for (int i = 0; i < 10; ++i) {
        std::string code = "TEST" + std::to_string(i);
        WTSTickData* tick = WTSTickData::create(code.c_str());
        ASSERT_NE(tick, nullptr);
        ticks.push_back(tick);
    }
    
    for (auto* tick : ticks) {
        tick->release();
    }
} 